import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
import { TOKEN_AUTH_STORAGE_NAME } from "./const";

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

export function saveAuthToken(token: string){
  localStorage.setItem(TOKEN_AUTH_STORAGE_NAME, token);
}

export function getAuthToken(): string | null{
  return localStorage.getItem(TOKEN_AUTH_STORAGE_NAME);
}

export function clearAuthToken(){
  localStorage.removeItem(TOKEN_AUTH_STORAGE_NAME);
}

export function isLogged(): boolean{
  return getAuthToken() ? true : false;
}
